const https = require('https');

// 设置请求选项
const options = {
    hostname: 'tqi.techlinkpets3d.com',
    port: 443,
    path: '/api/daka/person_rank',
    method: 'GET',
    headers: {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
    }
};

console.log('Sending request to API...');

const req = https.request(options, (res) => {
    console.log('Response Status Code:', res.statusCode);
    console.log('Response Headers:', res.headers);
    
    let data = '';
    
    res.on('data', (chunk) => {
        data += chunk;
    });
    
    res.on('end', () => {
        console.log('\n--- Raw Response Data ---');
        console.log('Response Length:', data.length);
        console.log('First 500 characters:');
        console.log(data.substring(0, 500));
        
        if (data.length > 500) {
            console.log('... (truncated)');
        }
        
        console.log('\n--- Attempting JSON Parse ---');
        try {
            const jsonData = JSON.parse(data);
            console.log('Successfully parsed JSON:');
            console.log(JSON.stringify(jsonData, null, 2));
        } catch (error) {
            console.log('Failed to parse JSON:');
            console.log('Error:', error.message);
            
            // 检查是否包含HTML标签
            if (data.includes('<html') || data.includes('<!DOCTYPE')) {
                console.log('Response appears to be HTML, not JSON');
            }
        }
    });
});

req.on('error', (error) => {
    console.log('Request Error:', error.message);
});

req.end();